<?php

namespace app\admin\model;

use app\common\model\Service;
use think\Model;

class Staff extends Model
{
    // 表名
    protected $name = 'staff';

    protected $append = [
        'service_text',
        'service1_text',
    ];

    public function getServiceTextAttr($value, $data)
    {
        $model = new Service();
        $res = $model->where('id','in',$data['service_ids'])->select();
        $text = [];
        foreach ($res as $item) {
            $text[] = $item['name'];
        }
//        return implode(',', $text);
        return implode($text);
    }

    public function getService1TextAttr($value, $data)
    {
        $model = new Service();
        $res = $model->where('id','in',$data['service1_ids'])->select();
        $text = [];
        foreach ($res as $item) {
            $text[] = $item['name'];
        }
//        return implode(',', $text);
        return implode($text);
    }
}
